import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_wifi_connector/flutter_wifi_connector.dart';
import 'package:flutter_wifi_connector/flutter_wifi_connector_platform_interface.dart';
import 'package:flutter_wifi_connector/flutter_wifi_connector_method_channel.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

class MockFlutterWifiConnectorPlatform
    with MockPlatformInterfaceMixin
    implements FlutterWifiConnectorPlatform {

  @override
  Future<String?> getPlatformVersion() => Future.value('42');

  @override
  Future<Map<String, dynamic>> connectToWifi(String ssid, String password) => Future.value({
    'success': true,
    'message': 'Successfully connected to $ssid. Network saved to device.',
  });
}

void main() {
  final FlutterWifiConnectorPlatform initialPlatform = FlutterWifiConnectorPlatform.instance;

  test('$MethodChannelFlutterWifiConnector is the default instance', () {
    expect(initialPlatform, isInstanceOf<MethodChannelFlutterWifiConnector>());
  });

  test('getPlatformVersion', () async {
    FlutterWifiConnector flutterWifiConnectorPlugin = FlutterWifiConnector();
    MockFlutterWifiConnectorPlatform fakePlatform = MockFlutterWifiConnectorPlatform();
    FlutterWifiConnectorPlatform.instance = fakePlatform;

    expect(await flutterWifiConnectorPlugin.getPlatformVersion(), '42');
  });

  test('connectToWifi', () async {
    FlutterWifiConnector flutterWifiConnectorPlugin = FlutterWifiConnector();
    MockFlutterWifiConnectorPlatform fakePlatform = MockFlutterWifiConnectorPlatform();
    FlutterWifiConnectorPlatform.instance = fakePlatform;

    final result = await flutterWifiConnectorPlugin.connectToWifi('TestSSID', 'password123');
    expect(result['success'], true);
    expect(result['message'], 'Successfully connected to TestSSID. Network saved to device.');
  });
}
